/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ControlLayer;

import DBLayer.DBSalesOrder;
import DBLayer.IFDBSalesOrder;
import ModelLayer.Customer;
import ModelLayer.Invoice;
import ModelLayer.SalesOrder;

/**
 *
 * @author Henrik-iMac
 */
public class CtrSalesOrder {
    public CtrSalesOrder(){
        
    }
    public SalesOrder findBySalesOrderId(int id, boolean retrieveAssociation){
        IFDBSalesOrder dBSalesOrder = new DBSalesOrder();
        return dBSalesOrder.findBySalesOrderId(id, retrieveAssociation);
    }

    public int insertSalesOrder(SalesOrder salesOrder){
        IFDBSalesOrder dBSalesOrder = new DBSalesOrder();
        return dBSalesOrder.insertSalesOrder(salesOrder);
    }

    public int updateSalesOrder(int id, String date, String deliveryStatus, String deliveryDate, Invoice invoice, Customer customer){
        IFDBSalesOrder dBSalesOrder = new DBSalesOrder();
        SalesOrder order = new SalesOrder();
        order.setId(id);
        order.setDate(date);
        order.setDeliveryStatus(deliveryStatus);
        order.setDeliverDate(deliveryDate);
        order.setInvoiceId(invoice);
        order.setCustomerId(customer);
        return dBSalesOrder.updateSalesOrder(order);
    }
    public int deleteSalesOrder(int id){
        IFDBSalesOrder dBSalesOrder = new DBSalesOrder();
        return dBSalesOrder.deleteSalesOrder(id);
    }
}
